]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
polkit: Find the best user to authenticate as
authorMatthias Clasen <mclasen@redhat.com>
Fri, 18 Nov 2011 03:42:37 +0000 (22:42 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 18 Nov 2011 22:28:58 +0000 (17:28 -0500)
We prefer to ask the user for his own password. If PolicyKit
is not configured to accept that, try the root password. If
PolicyKit does not accept that either, ask for password of
the first user that PolicyKit _will_ accept. The last case
is a bit broken, but should rarely occur in real-life
configurations.

https://bugzilla.gnome.org/show_bug.cgi?id=651547

js/ui/polkitAuthenticationAgent.js

index 2d7063ae8e892b0050d0d8eeacb6bd751f722197..6f01039756371ceac43455383b05cf5fdad2cc51 100644 (file)
@@ -27,6 +27,7 @@ const AccountsService = imports.gi.AccountsService;
 const Clutter = imports.gi.Clutter;
 const St = imports.gi.St;
 const Pango = imports.gi.Pango;
+const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Mainloop = imports.mainloop;
 const Polkit = imports.gi.Polkit;
@@ -88,10 +89,14 @@ AuthenticationDialog.prototype = {
         if (userNames.length > 1) {
             log('polkitAuthenticationAgent: Received ' + userNames.length +
                 ' identities that can be used for authentication. Only ' +
-                'considering the first one.');
+                'considering one.');
         }
 
-        let userName = userNames[0];
+        let userName = GLib.get_user_name();
+        if (userNames.indexOf(userName) < 0)
+            userName = 'root';
+        if (userNames.indexOf(userName) < 0)
+            userName = userNames[0];
 
         this._user = AccountsService.UserManager.get_default().get_user(userName);
         let userRealName = this._user.get_real_name()